package net.csdn.business.notify.common.utils;

import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.RandomUtil;
import cn.hutool.core.util.ReUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.crypto.digest.DigestUtil;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import net.csdn.business.notify.common.constant.CommonConstants;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.util.CollectionUtils;

import java.lang.reflect.Field;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;


/**
 * @ClassName StrUtils
 * @Description TODO
 * @Author zhangyl
 * @Date 2023/12/4 13:50
 */
public class StrUtils {

    public static String substring(String s, int len, String suffix) {
        if (StringUtils.isBlank(s) || s.length() <= len) {
            return s;
        }
        return StringUtils.substring(s, CommonConstants.INT_ZERO, len - suffix.length()) + suffix;
    }

    public static String substring(String s, int len) {
        return substring(s, len, "...");
    }


    public static String genDialogueId(String senderId,String receiverId){
        String[] ids = {senderId,receiverId};
        Arrays.sort(ids);
        String idStr=ids[0]+ids[1];
        return DigestUtil.md5Hex(idStr);

    }








}